home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / CIncludes / Devices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-17  |  12.3 KB  |  381 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Devices.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __DEVICES__
  18. #define __DEVICES__
  19.  
  20.  
  21. #ifndef __OSUTILS__
  22. #include <OSUtils.h>
  23. #endif
  24. /*    #include <Types.h>                                            */
  25. /*        #include <ConditionalMacros.h>                            */
  26. /*    #include <MixedMode.h>                                        */
  27.  
  28. #ifndef __FILES__
  29. #include <Files.h>
  30. #endif
  31.  
  32. #ifndef __QUICKDRAW__
  33. #include <Quickdraw.h>
  34. #endif
  35. /*    #include <QuickdrawText.h>                                    */
  36.  
  37. #ifndef __EVENTS__
  38. #include <Events.h>
  39. #endif
  40.  
  41. #ifndef __DIALOGS__
  42. #include <Dialogs.h>
  43. #endif
  44. /*    #include <Errors.h>                                            */
  45. /*    #include <Memory.h>                                            */
  46. /*    #include <Windows.h>                                        */
  47. /*        #include <Controls.h>                                    */
  48. /*            #include <Menus.h>                                    */
  49. /*    #include <TextEdit.h>                                        */
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55. #if GENERATINGPOWERPC
  56. #pragma options align=mac68k
  57. #endif
  58.  
  59. #ifdef __CFM68K__
  60. #pragma lib_export on
  61. #endif
  62.  
  63.  
  64. enum {
  65.     chooserInitMsg                = 11,                            /* the user selected this device package */
  66.     newSelMsg                    = 12,                            /* the user made new device selections */
  67.     fillListMsg                    = 13,                            /* fill the device list with choices */
  68.     getSelMsg                    = 14,                            /* mark one or more choices as selected */
  69.     selectMsg                    = 15,                            /* the user made a selection */
  70.     deselectMsg                    = 16,                            /* the user canceled a selection */
  71.     terminateMsg                = 17,                            /* allows device package to clean up */
  72.     buttonMsg                    = 19                            /* the user selected a button */
  73. };
  74.  
  75. /* Values of the 'caller' parameter to a Chooser device package */
  76. enum {
  77.     chooserID                    = 1
  78. };
  79.  
  80. /* Values of the 'message' parameter to a Control Panel 'cdev' */
  81. enum {
  82.     initDev                        = 0,                            /*Time for cdev to initialize itself*/
  83.     hitDev                        = 1,                            /*Hit on one of my items*/
  84.     closeDev                    = 2,                            /*Close yourself*/
  85.     nulDev                        = 3,                            /*Null event*/
  86.     updateDev                    = 4,                            /*Update event*/
  87.     activDev                    = 5,                            /*Activate event*/
  88.     deactivDev                    = 6,                            /*Deactivate event*/
  89.     keyEvtDev                    = 7,                            /*Key down/auto key*/
  90.     macDev                        = 8,                            /*Decide whether or not to show up*/
  91.     undoDev                        = 9,
  92.     cutDev                        = 10,
  93.     copyDev                        = 11,
  94.     pasteDev                    = 12,
  95.     clearDev                    = 13,
  96.     cursorDev                    = 14
  97. };
  98.  
  99. /* Special values a Control Panel 'cdev' can return */
  100. enum {
  101.     cdevGenErr                    = -1,                            /*General error; gray cdev w/o alert*/
  102.     cdevMemErr                    = 0,                            /*Memory shortfall; alert user please*/
  103.     cdevResErr                    = 1,                            /*Couldn't get a needed resource; alert*/
  104.     cdevUnset                    = 3                                /* cdevValue is initialized to this*/
  105. };
  106.  
  107. /* Values of the 'message' parameter to a Monitor 'mntr' */
  108. enum {
  109.     initMsg                        = 1,                            /*initialization*/
  110.     okMsg                        = 2,                            /*user clicked OK button*/
  111.     cancelMsg                    = 3,                            /*user clicked Cancel button*/
  112.     hitMsg                        = 4,                            /*user clicked control in Options dialog*/
  113.     nulMsg                        = 5,                            /*periodic event*/
  114.     updateMsg                    = 6,                            /*update event*/
  115.     activateMsg                    = 7,                            /*not used*/
  116.     deactivateMsg                = 8,                            /*not used*/
  117.     keyEvtMsg                    = 9,                            /*keyboard event*/
  118.     superMsg                    = 10,                            /*show superuser controls*/
  119.     normalMsg                    = 11,                            /*show only normal controls*/
  120.     startupMsg                    = 12                            /*code has been loaded*/
  121. };
  122.  
  123. /* control codes for DeskAccessories */
  124. enum {
  125.     goodbye                        = -1,                            /* heap being reinitialized */
  126.     killCode                    = 1,                            /* KillIO requested */
  127.     accEvent                    = 64,                            /* handle an event */
  128.     accRun                        = 65,                            /* time for periodic action */
  129.     accCursor                    = 66,                            /* change cursor shape */
  130.     accMenu                        = 67,                            /* handle menu item */
  131.     accUndo                        = 68,                            /* handle undo command */
  132.     accCut                        = 70,                            /* handle cut command */
  133.     accCopy                        = 71,                            /* handle copy command */
  134.     accPaste                    = 72,                            /* handle paste command */
  135.     accClear                    = 73                            /* handle clear command */
  136. };
  137.  
  138. /* miscellaneous Device Manager constants */
  139. enum {
  140.     ioInProgress                = 1,                            /* predefined value of ioResult while I/O is pending */
  141.     aRdCmd                        = 2,                            /* low byte of ioTrap for Read calls */
  142.     aWrCmd                        = 3,                            /* low byte of ioTrap for Write calls */
  143.     asyncTrpBit                    = 10,                            /* trap word modifier */
  144.     noQueueBit                    = 9                                /* trap word modifier */
  145. };
  146.  
  147. /* flags used in the driver header and device control entry */
  148. enum {
  149.     dReadEnable                    = 0,                            /* set if driver responds to read requests */
  150.     dWritEnable                    = 1,                            /* set if driver responds to write requests */
  151.     dCtlEnable                    = 2,                            /* set if driver responds to control requests */
  152.     dStatEnable                    = 3,                            /* set if driver responds to status requests */
  153.     dNeedGoodBye                = 4,                            /* set if driver needs time for performing periodic tasks */
  154.     dNeedTime                    = 5,                            /* set if driver needs time for performing periodic tasks */
  155.     dNeedLock                    = 6,                            /* set if driver must be locked in memory as soon as it is opened */
  156.     dNeedLockMask                = 0x4000,                        /* set if driver must be locked in memory as soon as it is opened */
  157.     dNeedTimeMask                = 0x2000,                        /* set if driver needs time for performing periodic tasks */
  158.     dNeedGoodByeMask            = 0x1000,                        /* set if driver needs to be called before the application heap is initialized */
  159.     dStatEnableMask                = 0x0800,                        /* set if driver responds to status requests */
  160.     dCtlEnableMask                = 0x0400,                        /* set if driver responds to control requests */
  161.     dWritEnableMask                = 0x0200,                        /* set if driver responds to write requests */
  162.     dReadEnableMask                = 0x0100                        /* set if driver responds to read requests */
  163. };
  164.  
  165. /* run-time flags used in the device control entry */
  166. enum {
  167.     dOpened                        = 5,                            /* driver is open */
  168.     dRAMBased                    = 6,                            /* dCtlDriver is a handle (1) or pointer (0) */
  169.     drvrActive                    = 7,                            /* driver is currently processing a request */
  170.     drvrActiveMask                = 0x0080,                        /* driver is currently processing a request */
  171.     dRAMBasedMask                = 0x0040,                        /* dCtlDriver is a handle (1) or pointer (0) */
  172.     dOpenedMask                    = 0x0020                        /* driver is open */
  173. };
  174.  
  175. struct DRVRHeader {
  176.     short                            drvrFlags;
  177.     short                            drvrDelay;
  178.     short                            drvrEMask;
  179.     short                            drvrMenu;
  180.     short                            drvrOpen;
  181.     short                            drvrPrime;
  182.     short                            drvrCtl;
  183.     short                            drvrStatus;
  184.     short                            drvrClose;
  185.     unsigned char                    drvrName[1];
  186. };
  187. typedef struct DRVRHeader DRVRHeader;
  188.  
  189. typedef DRVRHeader *DRVRHeaderPtr, **DRVRHeaderHandle;
  190.  
  191. struct DCtlEntry {
  192.     Ptr                                dCtlDriver;
  193.     short                            dCtlFlags;
  194.     QHdr                            dCtlQHdr;
  195.     long                            dCtlPosition;
  196.     Handle                            dCtlStorage;
  197.     short                            dCtlRefNum;
  198.     long                            dCtlCurTicks;
  199.     WindowPtr                        dCtlWindow;
  200.     short                            dCtlDelay;
  201.     short                            dCtlEMask;
  202.     short                            dCtlMenu;
  203. };
  204. typedef struct DCtlEntry DCtlEntry;
  205.  
  206. typedef DCtlEntry *DCtlPtr, **DCtlHandle;
  207.  
  208. struct AuxDCE {
  209.     Ptr                                dCtlDriver;
  210.     short                            dCtlFlags;
  211.     QHdr                            dCtlQHdr;
  212.     long                            dCtlPosition;
  213.     Handle                            dCtlStorage;
  214.     short                            dCtlRefNum;
  215.     long                            dCtlCurTicks;
  216.     GrafPtr                            dCtlWindow;
  217.     short                            dCtlDelay;
  218.     short                            dCtlEMask;
  219.     short                            dCtlMenu;
  220.     SInt8                            dCtlSlot;
  221.     SInt8                            dCtlSlotId;
  222.     long                            dCtlDevBase;
  223.     Ptr                                dCtlOwner;
  224.     SInt8                            dCtlExtDev;
  225.     SInt8                            fillByte;
  226.     UInt32                            dCtlNodeID;
  227.     UInt32                            dCtlDispMode;
  228. };
  229. typedef struct AuxDCE AuxDCE;
  230.  
  231. typedef AuxDCE *AuxDCEPtr, **AuxDCEHandle;
  232.  
  233. typedef pascal long (*ControlPanelDefProcPtr)(short message, short item, short numItems, short cPanelID, EventRecord *theEvent, long cdevValue, DialogPtr cpDialog);
  234.  
  235. #if GENERATINGCFM
  236. typedef UniversalProcPtr ControlPanelDefUPP;
  237. #else
  238. typedef ControlPanelDefProcPtr ControlPanelDefUPP;
  239. #endif
  240.  
  241. enum {
  242.     uppControlPanelDefProcInfo = kPascalStackBased
  243.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  244.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  245.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  246.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  247.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  248.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(EventRecord*)))
  249.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(long)))
  250.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(DialogPtr)))
  251. };
  252.  
  253. #if GENERATINGCFM
  254. #define NewControlPanelDefProc(userRoutine)        \
  255.         (ControlPanelDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlPanelDefProcInfo, GetCurrentArchitecture())
  256. #else
  257. #define NewControlPanelDefProc(userRoutine)        \
  258.         ((ControlPanelDefUPP) (userRoutine))
  259. #endif
  260.  
  261. #if GENERATINGCFM
  262. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  263.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppControlPanelDefProcInfo, (message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  264. #else
  265. #define CallControlPanelDefProc(userRoutine, message, item, numItems, cPanelID, theEvent, cdevValue, cpDialog)        \
  266.         (*(userRoutine))((message), (item), (numItems), (cPanelID), (theEvent), (cdevValue), (cpDialog))
  267. #endif
  268.  
  269. extern pascal DCtlHandle GetDCtlEntry(short refNum);
  270. /*
  271.     SetChooserAlert used to simply set a bit in a low-mem global
  272.     to tell the Chooser not to display its warning message when
  273.     the printer is changed. However, under MultiFinder and System 7,
  274.     this low-mem is swapped out when a layer change occurs, and the
  275.     Chooser never sees the change. It is obsolete, and completely
  276.     unsupported on the PowerPC. 68K apps can still call it if they
  277.     wish.
  278. */
  279. #if OLDROUTINENAMES && !GENERATINGCFM
  280. extern pascal Boolean SetChooserAlert(Boolean f);
  281. #endif
  282. /*
  283.   Note: DrvrInstall() is no longer supported, becuase it never really worked anyways.
  284.           There will soon be a DriverInstall() which does the right thing.
  285.         
  286.         DrvrRemove has been renamed to DriverRemove.  But, InterfaceLib for PowerPC
  287.         still exports DrvrRemove, so a macro is used to map the new name to old.
  288.  
  289. */
  290.  
  291. #if !GENERATINGCFM
  292. #pragma parameter __D0 DrvrRemove(__D0)
  293. #endif
  294. extern pascal OSErr DrvrRemove(short refNum)
  295.  ONEWORDINLINE(0xA03E);
  296. #define DriverRemove(refNum) DrvrRemove(refNum)
  297. extern pascal OSErr OpenDriver(ConstStr255Param name, short *drvrRefNum);
  298. extern pascal OSErr CloseDriver(short refNum);
  299. extern pascal OSErr Control(short refNum, short csCode, const void *csParamPtr);
  300. extern pascal OSErr Status(short refNum, short csCode, void *csParamPtr);
  301. extern pascal OSErr KillIO(short refNum);
  302.  
  303. #if !GENERATINGCFM
  304. #pragma parameter __D0 PBControlSync(__A0)
  305. #endif
  306. extern pascal OSErr PBControlSync(ParmBlkPtr paramBlock)
  307.  ONEWORDINLINE(0xA004);
  308.  
  309. #if !GENERATINGCFM
  310. #pragma parameter __D0 PBControlAsync(__A0)
  311. #endif
  312. extern pascal OSErr PBControlAsync(ParmBlkPtr paramBlock)
  313.  ONEWORDINLINE(0xA404);
  314.  
  315. #if !GENERATINGCFM
  316. #pragma parameter __D0 PBControlImmed(__A0)
  317. #endif
  318. extern pascal OSErr PBControlImmed(ParmBlkPtr paramBlock)
  319.  ONEWORDINLINE(0xA204);
  320.  
  321. #if !GENERATINGCFM
  322. #pragma parameter __D0 PBStatusSync(__A0)
  323. #endif
  324. extern pascal OSErr PBStatusSync(ParmBlkPtr paramBlock)
  325.  ONEWORDINLINE(0xA005);
  326.  
  327. #if !GENERATINGCFM
  328. #pragma parameter __D0 PBStatusAsync(__A0)
  329. #endif
  330. extern pascal OSErr PBStatusAsync(ParmBlkPtr paramBlock)
  331.  ONEWORDINLINE(0xA405);
  332.  
  333. #if !GENERATINGCFM
  334. #pragma parameter __D0 PBStatusImmed(__A0)
  335. #endif
  336. extern pascal OSErr PBStatusImmed(ParmBlkPtr paramBlock)
  337.  ONEWORDINLINE(0xA205);
  338.  
  339. #if !GENERATINGCFM
  340. #pragma parameter __D0 PBKillIOSync(__A0)
  341. #endif
  342. extern pascal OSErr PBKillIOSync(ParmBlkPtr paramBlock)
  343.  ONEWORDINLINE(0xA006);
  344.  
  345. #if !GENERATINGCFM
  346. #pragma parameter __D0 PBKillIOAsync(__A0)
  347. #endif
  348. extern pascal OSErr PBKillIOAsync(ParmBlkPtr paramBlock)
  349.  ONEWORDINLINE(0xA406);
  350.  
  351. #if !GENERATINGCFM
  352. #pragma parameter __D0 PBKillIOImmed(__A0)
  353. #endif
  354. extern pascal OSErr PBKillIOImmed(ParmBlkPtr paramBlock)
  355.  ONEWORDINLINE(0xA206);
  356. extern pascal short OpenDeskAcc(ConstStr255Param deskAccName)
  357.  ONEWORDINLINE(0xA9B6);
  358. extern pascal void CloseDeskAcc(short refNum)
  359.  ONEWORDINLINE(0xA9B7);
  360. #if CGLUESUPPORTED
  361. extern short opendeskacc(const char *deskAccName);
  362. extern OSErr opendriver(const char *driverName, short *refNum);
  363. #endif
  364. #define PBControl(pb, async) ((async) ? PBControlAsync(pb) : PBControlSync(pb))
  365. #define PBStatus(pb, async) ((async) ? PBStatusAsync(pb) : PBStatusSync(pb))
  366. #define PBKillIO(pb, async) ((async) ? PBKillIOAsync(pb) : PBKillIOSync(pb))
  367.  
  368. #ifdef __CFM68K__
  369. #pragma lib_export off
  370. #endif
  371.  
  372. #if GENERATINGPOWERPC
  373. #pragma options align=reset
  374. #endif
  375.  
  376. #ifdef __cplusplus
  377. }
  378. #endif
  379.  
  380. #endif /* __DEVICES__ */
  381.